﻿using System;
using System.Collections.Generic;
using BIS.Portal.Modules.CMS.Entity;
using BIS.Portal.Modules.CMS.DAL;

namespace BIS.Portal.Modules.CMS.BO
{
    public class AdminCmsArticleBO
    {
        /// <summary>
        /// Gets the by language in use id.
        /// </summary>
        /// <param name="languageInUseId">The language in use id.</param>
        /// <returns></returns>
        //public static IList<AdminCmsArticleEntity> GetByLanguageInUseId(int languageInUseId)
        //{
        //    return AdminCmsArticleDAL.GetByLanguageInUseId(languageInUseId);
        //}

        /// <summary>
        /// Gets the by language in use id.
        /// </summary>
        /// <returns></returns>
        public static AdminCmsArticleEntity GetByArticleId(int articleId)
        {
            return AdminCmsArticleDAL.GetByArticleId(articleId);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public static AdminCmsArticleIndependentEntity GetByArticleIndependentId(int articleId)
        {
            return AdminCmsArticleDAL.GetByArticleIndependentId(articleId);
        }
        public static void GetLastArticleId(ref int last_articleId)
        {
            AdminCmsArticleDAL.GetLastArticleId(ref last_articleId);
        }

        /// <summary>
        /// Deletes the article.
        /// </summary>
        /// <returns></returns>
        public static bool DeleteArticle(int articleId)
        {
            return (AdminCmsArticleDAL.DeleteArticle(articleId) > 0);
        }     

        /// <param name="keyword">The keyword.</param>
        /// <param name="languageInUseId"></param>
        /// <param name="categoryId"></param>
        /// <param name="isHotArticle"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static IList<AdminCmsArticleEntity> SearchArticle(string keyword, int categoryId, int isHotArticle, int status, int languageInUseId, DateTime? postDateStart, DateTime? postDateEnd)
        {
            return AdminCmsArticleDAL.SearchArticle(keyword, categoryId, isHotArticle, status, languageInUseId, postDateStart, postDateEnd);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="categoryId"></param>
        /// <param name="isHotArticle"></param>
        /// <param name="status"></param>
        /// <param name="languageInUseId"></param>
        /// <param name="postDateStart"></param>
        /// <param name="postDateEnd"></param>
        /// <returns></returns>
        public static IList<AdminCmsArticleEntity> SearchArticleNotSpecialDisplay(string keyword, int categoryId, int isHotArticle, int status, int languageInUseId, DateTime? postDateStart, DateTime? postDateEnd)
        {
            return AdminCmsArticleDAL.SearchArticleNotSpecialDisplay(keyword, categoryId, isHotArticle, status, languageInUseId, postDateStart, postDateEnd);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="keyword"></param>
        /// <param name="status"></param>
        /// <param name="languageInUseId"></param>
        /// <param name="postDateStart"></param>
        /// <param name="postDateEnd"></param>
        /// <returns></returns>
        public static IList<AdminCmsArticleIndependentEntity> SearchArticleIndependent(string keyword, int status, int languageInUseId, DateTime? postDateStart, DateTime? postDateEnd)
        {
            return AdminCmsArticleDAL.SearchArticleIndependent(keyword, status, languageInUseId, postDateStart, postDateEnd);
        }
        /// <summary>
        /// Updates the Article.
        /// </summary>
        /// <returns></returns>
        public static bool UpdateArticle(AdminCmsArticleEntity entity)
        {
            return (AdminCmsArticleDAL.UpdateArticle(entity) > 0);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool UpdateArticleIndependent(AdminCmsArticleIndependentEntity entity)
        {
            return (AdminCmsArticleDAL.UpdateArticleIndependent(entity) > 0);
        }
       
        /// <summary>
        /// Updates the status.
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="status">The status.</param>
        /// <param name="isHotArticle">The Is Hot Article</param>
        /// <returns></returns>
        public static bool UpdateStatusInPage(int articleId, int status, int isHotArticle)
        {
            return AdminCmsArticleDAL.UpdateStatusInPage(articleId, status, isHotArticle) > 0;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public static bool AddArticle(AdminCmsArticleEntity entity)
        {            
            return AdminCmsArticleDAL.AddArticle(entity)>0;
        }

        public static bool AddArticleIndependent(AdminCmsArticleIndependentEntity entity)
        {
            return AdminCmsArticleDAL.AddArticleIndependent(entity) > 0;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="status"></param>
        /// <param name="isHotArticle"></param>
        /// <returns></returns>
        public static bool UpdateStatusInPage2(int articleId, int status)
        {
            return AdminCmsArticleDAL.UpdateStatusInPage2(articleId, status) > 0;
        }
        /// <summary>
        /// Kiểm tra Article đã tồn tại chưa?
        /// </summary>
        /// <param name="iArticle_id"></param>
        /// <param name="iCheck_count"></param>
        public static void CheckArticleId(int iArticle_id, ref int iCheck_count)
        {
            AdminCmsArticleDAL.CheckArticleId(iArticle_id,ref iCheck_count);
        }
    }
}
